﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Net7Docker.FrameWork
{
    /// <summary>
    /// 配置文杰管理类==》固定读取Orm根目录的appsettings.json文件
    /// </summary>
    public class ConfigurationManager
    {
        //类实例化顺序==》最新执行静态构造函数 确保一定能拿到对象
        static ConfigurationManager()
        {
            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");

            IConfigurationRoot configuration = builder.Build();

            _SqlConnectString = configuration["ConnectString"];
        }

        private static string _SqlConnectString = null;
        public static string SqlConnectString
        {
            get
            {
                return _SqlConnectString;
            }
        }
    }
}
